# -*- coding: utf-8 -*-
# @Time    : 2019/10/17 10:15
# @Author  : LiHaowen
# @Email   : lihaowen2017@163.com
# @File    : set_test.py

# set 集合 fronzenset(不可变集合) 无序，不重复

s = set("abbcde")  # 接受一个可迭代的对象
s.add("f")
print(s)

s1 = frozenset("abcde")  # frozenset可以作为dict的key

# 向set添加数据
another_set = set("defg")
s.update(another_set)  # 更新数据
print(s)

re_set = s.difference(another_set)  # 差集，拥有返回值返回一个新set
# set 性能高
# | & - # 集合运算
re_set = s - another_set
re_set = s & another_set
re_set = s | another_set
print(s.issubset(re_set))  # 判断是否为子集
print(re_set)
